<template>
  <div>
    <a-card :bordered="false" style="margin-bottom: 10px">
      <!-- 查询区域 -->
      <a-form-model :label-col="labelCol" :wrapper-col="wrapperCol" @keyup.enter.native="onQuery">
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="计划名称">
              <a-input v-model="pageFilter.realName" placeholder="请输入" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="计划编号">
              <a-input v-model="pageFilter.realName" placeholder="请输入" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="考核类型">
              <a-select v-model="pageFilter.personType" placeholder="请选择" style="width:100%;" allowClear>
                <a-select-option v-for="(item, key) in examType" :key="key" :value="item.value">{{ item.title }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="考核状态">
              <a-select v-model="pageFilter.personType" placeholder="请选择" style="width:100%;" allowClear>
                <a-select-option v-for="(item, key) in examStatus" :key="key" :value="item.value">{{ item.title }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="考核时间" >
              <a-date-picker v-model:value="queryParam.createDate" style="width:100%;"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="指标名称">
              <a-input v-model="pageFilter.realName" placeholder="请输入" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-card>
    <a-card>
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <div>
          <a-button type="primary" @click="handleProcess()">自评</a-button>
        </div>
      </div>
      <div class="table-page-content">
        <z-table ref="table" rowKey="id" :showAlert="false" :showSelection="true" :loading="loading"
                 :columns="columns" :dataSource="pageData" @selectedRow="onSelectedRow" @change="onTableChange">
          <!--操作-->
          <template slot="action" slot-scope="text, record">
            <a-button type="link" style="padding: 0" @click.stop="onDetail(record)">详情</a-button>
          </template>
        </z-table>
      </div>
    </a-card>
  </div>

</template>

<script>
  import { getDictItemsFromCache } from '@/api/api'
  import * as treatApi from '@/api/sjsk/help/helpPlan.js'

  export default {
    name: "selfExamine",
    components: {
    },
    data() {
      return {
        labelCol: { span: 6 },
        wrapperCol: { span: 17 },
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: 'order',
            width: 60,
            align: 'center',
            customRender: (text, record, index) =>
              `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
          },
          {
            title: '指标名称',
            align: "center",
            dataIndex: 'esTitle'
          },
          {
            title: '指标类型',
            align: "center",
            dataIndex: 'esContent',
          },
          {
            title: '基数',
            align: "center",
            dataIndex: 'esReceiver'
          },
          {
            title: '任务量',
            align: "center",
            dataIndex: 'esSendNum'
          },
          {
            title: '完成量',
            align: 'center',
            dataIndex: 'esSendStatus_dictText'
          },
          {
            title: '加/减分基数',
            align: 'center',
            dataIndex: 'esSendStatus_dictText1'
          },
          {
            title: '上限分值',
            align: 'center',
            dataIndex: 'esSendStatus_dictText2'
          },
          {
            title: '下限分值',
            align: 'center',
            dataIndex: 'esSendStatus_dictTex3t'
          },
          {
            title: '权重(%)',
            align: 'center',
            dataIndex: 'esSendStatus_dictTex4t'
          },
          {
            title: '是否可修正得分',
            align: 'center',
            dataIndex: 'esSendStatus_dictText5'
          },
          {
            title: '是否与上级共享评分',
            align: 'center',
            dataIndex: 'esSendStatus_dictText6'
          },
          {
            title: '是否禁用',
            align: 'center',
            dataIndex: 'esSendStatus_dictText8'
          },
          {
            title: '考核得分',
            align: 'center',
            dataIndex: 'kaohe',
          },
          {
            title: '复议得分',
            align: 'center',
            dataIndex: 'ziping',
          },
        ],
        typeArr: getDictItemsFromCache('personType'),
        loading: false,
        pageFilter: {
          pageNo: 1,
          pageSize: 10,
        },
        queryParam:{},
        pageData: {},
        examType:[
          {
            value:'year',
            title:'年度'
          },{
            value:'ji',
            title:'季度'
          },{
            value:'month',
            title:'月度'
          }],
      }
    },
    created(){
      this.componentName = this.$route.meta.componentName
      console.info('this.componentName',this.componentName)
      this.onQuery()
    },
    methods: {
      // 查询
      onQuery() {
        this.pageFilter.pageNo = 1
        this.refreshTable()
      },
      // 重置
      onResetForm() {
        this.pageFilter = {
          pageNo: 1,
          pageSize: 10
        }
        this.refreshTable()
      },
      onSelectedRow(keys) {

      },
      onTableChange(pagination, pageFilter, sorter) {
        /* let keyMap = { currentPage: 'pageNo' }
         let paginations = Object.keys(pagination).reduce((newData, key) => {
           let newKey = keyMap[key] || key
           newData[newKey] = pagination[key]
           return newData
         }, {})
         this.pageFilter = Object.assign({}, this.pageFilter, paginations)
         this.refreshTable()*/
      },
      refreshTable() {
        this.loading = true
        treatApi.pageNew(this.pageFilter).then((res) => {
          if (res.success) {
            this.pageData = res.result ? res.result : {}
            this.loading = false
            this.$refs.table.onClearRowKeys()
          } else {
            this.loading = false
            this.pageData = {}
            this.$message.warn('请求失败！')
          }
        }).catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
      },
      onDetail(record) {
        this.$router.push({
          path: '/executeExamine/bgtDetails',
        })
      },
      handleProcess(){

      }
    }
  }
</script>
<style lang="less" scoped>

</style>